#ifndef P8X32ACOGPANEL_H
#define P8X32ACOGPANEL_H

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QGroupBox>
#include <QPlainTextEdit>
#include <QLabel>
#include <QLineEdit>
#include <QTableWidget>

#include "p8x32a.h"

class P8x32aCogPanel : public QWidget
{
    Q_OBJECT
public:
    explicit P8x32aCogPanel(QWidget *parent = 0);
    virtual  ~P8x32aCogPanel();
    void clearBreakpoints();
    void clearCogMem();
    void addCogInstructions(QList<uint> codeList);
    void setCodeLine(int pc, uint instruction, QList<uint> codeList, CogInfo *info = 0);
    void showCogPC(int pc);
    void showCog(CogInfo *info);
    void setCog(int num) { cog = num; }

private:

    int cog;

    enum { CODE_BRK = 0,
           CODE_INS,
           CODE_NAME,
           //CODE_OP,
           CODE_CND,
           CODE_WZ,
           CODE_WC,
           CODE_WR,
           CODE_DST,
           //CODE_IMM,
           CODE_SRC,
           CODE_CRES,
           CODE_ZRES,
           CODE_DRES
         };

    QVBoxLayout layout;
    QGroupBox   special;
    QGroupBox   instructions;
    QTableWidget  code;

    QLabel pcLabel;
    QLabel insLabel;
    QLabel zLabel;
    QLabel cLabel;
    QLabel cndLabel;
    QLabel srcLabel;
    QLabel dstLabel;
    QLabel resLabel;

    QLineEdit pcValue;
    QLineEdit insValue;
    QLineEdit zValue;
    QLineEdit cValue;
    QLineEdit cndValue;
    QLineEdit srcValue;
    QLineEdit dstValue;
    QLineEdit resValue;

    QLabel parLabel;
    QLabel cntLabel;
    QLabel inaLabel;
    QLabel inbLabel;
    QLabel outaLabel;
    QLabel outbLabel;
    QLabel diraLabel;
    QLabel dirbLabel;
    QLabel ctraLabel;
    QLabel ctrbLabel;
    QLabel frqaLabel;
    QLabel frqbLabel;
    QLabel phsaLabel;
    QLabel phsbLabel;
    QLabel vcfgLabel;
    QLabel vsclLabel;

    QLineEdit parValue;
    QLineEdit cntValue;
    QLineEdit inaValue;
    QLineEdit inbValue;
    QLineEdit outaValue;
    QLineEdit outbValue;
    QLineEdit diraValue;
    QLineEdit dirbValue;
    QLineEdit ctraValue;
    QLineEdit ctrbValue;
    QLineEdit frqaValue;
    QLineEdit frqbValue;
    QLineEdit phsaValue;
    QLineEdit phsbValue;
    QLineEdit vcfgValue;
    QLineEdit vsclValue;

    QHash<QString,int> brkHash;

signals:
    void setBreakpoint(int r, int cog);
    void clearBreakpoint(int r, int cog);

public slots:
    void cellClicked(int r, int c);
};

#endif // P8X32ACOGPANEL_H
